<?php

namespace app\common\model;

use think\Env;
use think\Exception;
use think\Model;

/**
 * 模型
 */
class Service extends Model
{

    // 表名
    protected $name = 'service';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;


    // 追加属性
    protected $append = [

    ];
    public function setLogoAttr($value)
    {
        if (!empty($value)){
            $arr = parse_url($value);
            return $arr['path'];
        }
        return '';
    }

    public function setSelectLogoAttr($value)
    {
        if (!empty($value)){
            $arr = parse_url($value);
            return $arr['path'];
        }
        return '';
    }

    public function getLogoAttr($value) {
        return $value ? Env::get('app.app_host').$value : '';
    }

    public function getSelectLogoAttr($value) {
        return $value ? Env::get('app.app_host').$value : '';
    }

    //车主端
    public static function getService($field = 'id,name,logo,select_logo,shop,client')
    {
        return self::field($field)->where(['status'=>1,'client_show'=>1])->order('sort asc')->select();
    }

    //商家端
    public static function getShopService($field = 'id,name,logo,select_logo,shop,client')
    {
        return self::field($field)->where(['status'=>1])->order('sort desc')->select();
    }








}
